@extends('layouts.app')

@section('content')
    <link href="https://cdn.bootcss.com/Swiper/4.3.0/css/swiper.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/Swiper/4.3.0/js/swiper.min.js"></script>
    <div class="container">
        <div class="row">
            {{--推荐文章区域--}}
            <div class="col-sm-9">
                <div class="card">
                    <div class="card-header">
                        {{$aid['title']}}
                    </div>
                    <div class="card-body">
                        {!! $aid['content'] !!}
                    </div>
                </div>
            </div>
            {{--推荐文章区域--}}
            {{--热门文章区域--}}
            <div class="col-sm-3">
                <div class="card">
                    <div class="card-header">
                        热门文章
                    </div>
                    <div class="card-block">
                        <ul class="list-group">
                            @wenzhang(['hot'=>1])
                            <li class="list-group-item">
                                <a href="{{$a['url']}}">{{$a['title']}}</a>
                            </li>
                            @endwenzhang
                        </ul>
                    </div>
                </div>
            </div>
            {{--热门文章区域--}}
        </div>
    </div>
    <div class="container mt-4">
        <div class="row">
            <div class="col-sm-9">
                <div class="card">
                    <div class="card-header">
                        用户评论
                    </div>
                    <div class="card-block mt-2 mb-2">
                        {{--当前文章已经评论过的内容--}}
                        <ul class="list-group">

                            @foreach($dc as $v)
                            <li class="list-group-item">
                                <div class="row">
                                    <div class="col-sm-9">
                                        {{$v['content']}}
                                    </div>
                                    <div class="col-sm-3 text-right">
                                        <small>{{$v->lp->name}} / {{$v['created_at']->diffForHumans()}}</small>
                                    </div>
                                </div>
                            </li>
                                @endforeach
                        </ul>
                        {{--当前文章已经评论过的内容--}}
                    </div>

                    {{--最后一步：用户没登录就让他先登录，然后再评论--}}
                    @if(auth()->check())
                    <form action="{{route('comment.store')}}" method="post">
                        @csrf
                        <input type="hidden" name="article_id" value="{{$aid['id']}}">
                    <textarea style="width: 100%;" class="form-control" placeholder="请留下你想说的..." name="content" rows="5"></textarea>

                    <div class="card-footer text-muted">
                        <button type="submit" class="btn btn-success">立即评论</button>
                    </div>

                    </form>
                    @else

                        <a href="{{route('login')}}" class="btn btn-success">请登录后提交评论</a>

                        @endif
                </div>
            </div>
        </div>
    </div>
@endsection